import json

from Config.Config import get_redis_client


def retrieve_params_from_redis_Dispose():
    key = "retrieve_params_from_redis_Dispose"

    # 从Redis获取JSON格式的数据
    redis_client = get_redis_client()
    json_data = redis_client.get(key)
    if json_data:
        json_data = json_data.decode('utf-8')
    print(json_data)

    if json_data is not None:
        # 将JSON字符串反序列化为Python字典
        params_dict = json.loads(json_data)

        # 现在可以从字典中提取所需参数
        data = params_dict['data_url']
        dataName = params_dict['data_name']
        typeMethod = params_dict['typeMethod']
        strategy = params_dict['strategy']
        n_neighbors = params_dict['n_neighbors']

        return data, dataName, typeMethod, strategy, n_neighbors
    else:
        print("没有在Redis中找到对应的参数")
        # 根据需要返回默认值或者抛出异常
        return "redis中无参数"
